from django.db import models
from api.subject_management.models import Subject
from api.experiment_management.models import Experiment
from api.attachment_management.models import AlloyPhaseDiagram
import django.utils.timezone as timezone

# Create your models here.


class Sample(models.Model):
    """
    样品model，定义了样品的相关属性
    """
    sample_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                 verbose_name='sample_id')  # 样品信息id
    subject_name = models.ForeignKey(Subject, on_delete=models.CASCADE, db_column='subject_name',
                                     verbose_name='subject_name')  # 课题名称
    experiment_name = models.ForeignKey(Experiment, on_delete=models.CASCADE,
                                        db_column='experiment_name',
                                        verbose_name='experiment_name')  # 实验名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    sample_name = models.TextField(
        null=False, blank=False, verbose_name='sample_name')  # 样品名称
    english_name = models.TextField(
        null=True, blank=True, verbose_name='english_name')  # 英文名称
    alias = models.TextField(null=True, blank=True, verbose_name='alias')  # 别名
    production_unit = models.TextField(
        null=True, blank=True, verbose_name='production_unit')  # 生产单位
    application_overview = models.TextField(
        null=True, blank=True, verbose_name='application_overview')  # 应用概况
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    data_source_attachment = models.FileField(upload_to='sample/dataSourceAttachment/%Y/%m/%d/%H%M%S/', null=True,
                                              blank=True, verbose_name='data_source_attachment')  # 数据来源附件
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'sample'  # 内嵌类指定样品信息表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_sample', u'查看样品'),
            ('add_sample', u'添加样品'),
            ('delete_sample', u'删除样品'),
            ('change_sample', u'修改样品'),
        )


class MacroOrganization(models.Model):
    """
    宏观组织model，定义了宏观形貌相关属性
    """
    macro_organization_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                             verbose_name='macro_organization_id')  # 宏观组织id
    sample_name = models.TextField(
        null=False, blank=False, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    sample_form = models.TextField(
        null=True, blank=True, verbose_name='sample_form')  # 形态
    sample_shape = models.TextField(
        null=True, blank=True, verbose_name='sample_shape')  # 形状
    sample_length = models.TextField(
        null=True, blank=True, verbose_name='sample_length')  # 长
    sample_width = models.TextField(
        null=True, blank=True, verbose_name='sample_width')  # 宽
    sample_thickness = models.TextField(
        null=True, blank=True, verbose_name='sample_thickness')  # 厚度
    sample_diameter = models.TextField(
        null=True, blank=True, verbose_name='sample_diameter')  # 直径
    sample_col = models.TextField(
        null=True, blank=True, verbose_name='sample_col')  # 颜色
    sample_gloss = models.TextField(
        null=True, blank=True, verbose_name='sample_gloss')  # 光泽度
    sample_roughness = models.TextField(
        null=True, blank=True, verbose_name='sample_roughness')  # 粗糙度
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'macro_organization'  # 内嵌类指定宏观组织表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_macro_organization', u'查看宏观组织'),
            ('add_macro_organization', u'添加宏观组织'),
            ('delete_macro_organization', u'删除宏观组织'),
            ('change_macro_organization', u'修改宏观组织'),
        )


class MicroStructure(models.Model):
    """
    微观组织model，定义了微观组织相关属性
    """
    micro_structure_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                          verbose_name='micro_structure_id')  # 微观组织id
    sample_name = models.TextField(
        null=False, blank=False, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    organization_structure = models.TextField(null=True, blank=True,
                                              verbose_name='organization_structure')  # 组织结构
    second_phase = models.FileField(null=True, blank=True, upload_to='microStructure/secondPhase/%Y/%m/%d/%H%M%S/',
                                    verbose_name='second_phase')  # 第二相形态
    grain_morphology = models.FileField(upload_to='microStructure/grainMorphology/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                        verbose_name='grain_morphology')  # 晶粒形态
    average_grain_size = models.TextField(
        null=True, blank=True, verbose_name='average_grain_size')  # 平均晶粒尺寸
    second_phase_size = models.TextField(
        null=True, blank=True, verbose_name='second_phase_size')  # 第二相尺寸
    fracture_type = models.TextField(
        null=True, blank=True, verbose_name='fracture_type')  # 断裂类型
    fracture_morphology = models.FileField(upload_to='microStructure/fracture_morphology/%Y/%m/%d/%H%M%S/',
        null=True, blank=True, verbose_name='fracture_morphology')  # 断口形貌
    corrosion_morphology = models.FileField(upload_to='microStructure/corrosionMorphology/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                            verbose_name='corrosion_morphology')  # 腐蚀形貌
    oxidation_morphology = models.FileField(upload_to='microStructure/oxidationMorphology/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                            verbose_name='oxidation_morphology')  # 氧化形貌
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'micro_structure'  # 内嵌类指定微观组织表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_micro_structure', u'查看微观组织'),
            ('add_micro_structure', u'添加微观组织'),
            ('delete_micro_structure', u'删除微观组织'),
            ('change_micro_structure', u'修改微观组织'),
        )


class ChemicalProperties(models.Model):
    """
    化学性能model，定义了化学性能的相关属性
    """
    chemical_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                              verbose_name='chemical_properties_id')  # 化学性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    corrosion_potential = models.TextField(
        null=True, blank=True, verbose_name='corrosion_potential')  # 腐蚀电位
    corrosion_current = models.TextField(
        null=True, blank=True, verbose_name='corrosion_current')  # 腐蚀电流
    erosion = models.TextField(
        null=True, blank=True, verbose_name='erosion')  # 渗蚀度
    passivation_current = models.TextField(
        null=True, blank=True, verbose_name='passivation_current')  # 钝化电流
    polarization_curve = models.FileField(upload_to='chemicalProperties/polarizationCurve/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                          verbose_name='polarization_curve')  # 极化曲线
    open_circuit_potential = models.TextField(
        null=True, blank=True, verbose_name='open_circuit_potential')  # 开路电位
    open_circuit_potential_curve = models.FileField(upload_to='chemicalProperties/openCircuitPotentialCurve/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                                    verbose_name='open_circuit_potential_curve')  # 开路电位曲线
    corrosion_rate = models.TextField(
        null=True, blank=True, verbose_name='corrosion_rate')  # 腐蚀速率
    tg_curve = models.FileField(upload_to='chemicalProperties/tgCurve/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                verbose_name='tg_curve')  # 热重曲线
    toxicity = models.TextField(
        null=True, blank=True, verbose_name='toxicity')  # 毒性
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'chemical_properties'  # 内嵌类指定化学性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_chemical_property', u'查看化学性能'),
            ('add_chemical_property', u'添加化学性能'),
            ('delete_chemical_property', u'删除化学性能'),
            ('change_chemical_property', u'修改化学性能'),
        )


class PhysicalProperties(models.Model):
    """
    物理性能model，定义了物理性能相关属性
    """
    physical_properties = models.AutoField(max_length=20, primary_key=True, unique=True,
                                           verbose_name='physical_properties')  # 物理性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    density = models.TextField(
        null=True, blank=True, verbose_name='density')  # 密度
    melting_point = models.TextField(
        null=True, blank=True, verbose_name='melting_point')  # 熔点
    boiling_point = models.TextField(
        null=True, blank=True, verbose_name='boiling_point')  # 沸点
    sample_density = models.TextField(
        null=True, blank=True, verbose_name='sample_density')  # 致密度
    conductivity = models.TextField(
        null=True, blank=True, verbose_name='conductivity')  # 电导率
    resistivity = models.TextField(
        null=True, blank=True, verbose_name='resistivity')  # 电阻率
    thermal_conductivity = models.TextField(
        null=True, blank=True, verbose_name='thermal_conductivity')  # 热导率
    thermal_expansion_coefficient = models.TextField(null=True, blank=True,
                                                     verbose_name='thermal_expansion_coefficient')  # 热膨胀系数
    permeability = models.TextField(
        null=True, blank=True, verbose_name='permeability')  # 导磁率
    magnetic_saturation = models.TextField(
        null=True, blank=True, verbose_name='magnetic_saturation')  # 磁饱和强度
    remanence = models.TextField(
        null=True, blank=True, verbose_name='remanence')  # 剩磁
    coercive_force = models.TextField(
        null=True, blank=True, verbose_name='coercive_force')  # 矫顽力
    liquid_temperature = models.TextField(
        null=True, blank=True, verbose_name='liquid_temperature')  # 液相线温度
    solidus_temperature = models.TextField(
        null=True, blank=True, verbose_name='solidus_temperature')  # 固相线温度
    melting_process = models.TextField(
        null=True, blank=True, verbose_name='melting_process')  # 熔程
    enthalpy = models.TextField(
        null=True, blank=True, verbose_name='enthalpy')  # 焓
    supercooling_degree = models.TextField(
        null=True, blank=True, verbose_name='supercooling_degree')  # 过冷度
    thermal_diffusion_coefficient = models.TextField(null=True, blank=True,
                                                     verbose_name='thermal_diffusion_coefficient')  # 热扩散系数
    specific_heat_capacity = models.TextField(
        null=True, blank=True, verbose_name='specific_heat_capacity')  # 比热容
    wetting_force = models.TextField(
        null=True, blank=True, verbose_name='wetting_force')  # 润湿力
    wetting_rate = models.TextField(
        null=True, blank=True, verbose_name='wetting_rate')  # 润湿率
    wetting_time = models.TextField(
        null=True, blank=True, verbose_name='wetting_time')  # 润湿时间
    spreading_rate = models.TextField(
        null=True, blank=True, verbose_name='spreading_rate')  # 铺展率
    spreading_square = models.TextField(
        null=True, blank=True, verbose_name='spreading_square')  # 铺展面积
    wetting_angle = models.TextField(
        null=True, blank=True, verbose_name='wetting_angle')  # 润湿角
    molar_heat_capacity = models.TextField(
        null=True, blank=True, verbose_name='molar_heat_capacity')  # 摩尔热容
    impedance = models.FileField(upload_to='physicalProperties/impedance/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                 verbose_name='impedance')  # 阻抗
    impedance_curve = models.FileField(upload_to='physicalProperties/impedanceCurve/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                       verbose_name='impedance_curve')  # 阻抗曲线
    radioactive = models.TextField(
        null=True, blank=True, verbose_name='radioactive')  # 放射性
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'physical_properties'  # 内嵌类指定物理性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_physical_property', u'查看物理性能'),
            ('add_physical_property', u'添加物理性能'),
            ('delete_physical_property', u'删除物理性能'),
            ('change_physical_property', u'修改物理性能'),
        )


class TensileMechanicalProperties(models.Model):
    """
    拉伸力学性能model，定义了拉伸力学性能的相关属性
    """
    tensile_mechanical_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                                        verbose_name='tensile_mechanical_properties_id')  # 拉伸力学性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(null=True, blank=True,
                                    verbose_name='device_model')  # 设备型号
    load = models.TextField(null=True, blank=True, verbose_name='load')  # 载荷
    stretching_rate = models.TextField(
        null=False, blank=False, verbose_name='stretching_rate')  # 拉伸速率
    strain_rate = models.TextField(
        null=False, blank=False, verbose_name='strain_rate')  # 应变速率
    sample_range = models.TextField(
        null=False, blank=False, verbose_name='sample_range')  # 样品标距
    sample_thickness = models.TextField(
        null=False, blank=False, verbose_name='sample_thickness')  # 样品厚度
    sample_width = models.TextField(
        null=False, blank=False, verbose_name='sample_width')  # 样品宽度
    test_temperature = models.TextField(
        null=False, blank=False, verbose_name='test_temperature')  # 测试温度
    young_modulus = models.TextField(
        null=True, blank=True, verbose_name='young_modulus')  # 杨氏模量
    yield_strength = models.TextField(
        null=True, blank=True, verbose_name='yield_strength')  # 屈服强度
    up_yield_strength = models.TextField(
        null=True, blank=True, verbose_name='up_yield_strength')  # 上屈服强度
    down_yield_strength = models.TextField(
        null=True, blank=True, verbose_name='down_yield_strength')  # 下屈服强度
    ultimate_tensile_strength = models.TextField(null=True, blank=True,
                                                 verbose_name='ultimate_tensile_strength')  # 极限抗拉强度
    fracture_strength = models.TextField(
        null=True, blank=True, verbose_name='fracture_strength')  # 断裂强度
    break_elongation = models.TextField(
        null=True, blank=True, verbose_name='break_elongation')  # 断后延伸率
    section_reduction = models.TextField(
        null=True, blank=True, verbose_name='section_reduction')  # 断面收缩率
    uniform_elongation = models.TextField(
        null=True, blank=True, verbose_name='uniform_elongation')  # 均匀延伸率
    true_stress = models.TextField(
        null=True, blank=True, verbose_name='true_stress')  # 真应力
    true_strain = models.TextField(
        null=True, blank=True, verbose_name='true_strain')  # 真应变
    work_hardening_rate = models.TextField(
        null=True, blank=True, verbose_name='work_hardening_rate')  # 加工硬化速率
    engineering_stress_strain = models.FileField(upload_to='tensileMechanicalProperties/engineeringStressStrain/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                                 verbose_name='engineering_stress_strain')  # 工程应力-应变曲线
    true_stress_strain = models.FileField(upload_to='tensileMechanicalProperties/trueStressStrain/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                          verbose_name='true_stress_strain')  # 真应力-应变曲线
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'tensile_properties'  # 内嵌类指定拉伸力学性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_tensile_property', u'查看拉伸力学性能'),
            ('add_tensile_property', u'添加拉伸力学性能'),
            ('delete_tensile_property', u'删除拉伸力学性能'),
            ('change_tensile_property', u'修改拉伸力学性能'),
        )


class CompressingMechanicalProperties(models.Model):
    """
    压缩力学性能model，定义了压缩力学性能的相关属性
    """
    compress_mechanical_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                                         verbose_name='compress_mechanical_properties_id')  # 压缩力学性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    compress_rate = models.TextField(
        null=True, blank=True, verbose_name='compress_rate')  # 压缩速率
    sample_height = models.TextField(
        null=True, blank=True, verbose_name='sample_height')  # 样品高度
    sample_diameter = models.TextField(
        null=True, blank=True, verbose_name='sample_diameter')  # 直径
    sample_length = models.TextField(
        null=True, blank=True, verbose_name='sample_length')  # 长
    sample_width = models.TextField(
        null=True, blank=True, verbose_name='sample_width')  # 宽
    test_temperature = models.TextField(
        null=True, blank=True, verbose_name='test_temperature')  # 测试温度
    compression_modulus = models.TextField(
        null=True, blank=True, verbose_name='compression_modulus')  # 压缩模量
    yield_strength = models.TextField(
        null=True, blank=True, verbose_name='yield_strength')  # 屈服强度
    ultimate_compress_strength = models.TextField(null=True, blank=True,
                                                  verbose_name='ultimate_compress_strength')  # 极限抗压强度
    fracture_strength = models.TextField(
        null=True, blank=True, verbose_name='fracture_strength')  # 断裂强度
    break_elongation = models.TextField(
        null=True, blank=True, verbose_name='break_elongation')  # 断后延伸率
    compress_stress_strain = models.FileField(upload_to='compressingMechanicalProperties/compress_stress_strain/%Y/%m/%d/%H%M%S/',
                                              null=True, blank=True,
                                              verbose_name='compress_stress_strain')  # 压缩应力-应变曲线
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'compress_properties'  # 内嵌类指定压缩力学性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_compress_property', u'查看压缩力学性能'),
            ('add_compress_property', u'添加压缩力学性能'),
            ('delete_compress_property', u'删除压缩力学性能'),
            ('change_compress_property', u'修改压缩力学性能'),
        )


class ShearProperties(models.Model):
    """
    剪切性能model，定义了剪切性能相关属性
    """
    shear_properties_id = models.AutoField(max_length=20, primary_key=True, blank=True,
                                           verbose_name='shear_properties_id')  # 剪切性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    temperature = models.TextField(
        null=True, blank=True, verbose_name='temperature')  # 温度
    cross_sectional_area = models.TextField(
        null=True, blank=True, verbose_name='cross_sectional_area')  # 横截面积
    shear_load = models.TextField(
        null=True, blank=True, verbose_name='shear_load')  # 剪切载荷
    shear_modules = models.TextField(
        null=True, blank=True, verbose_name='shear_modules')  # 剪切模量
    ultimate_shear_strength = models.TextField(null=True, blank=True,
                                               verbose_name='ultimate_shear_strength')  # 极限剪切强度
    shear_yield_strength = models.TextField(
        null=True, blank=True, verbose_name='shear_yield_strength')  # 剪切降伏强度
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'shear_properties'  # 内嵌类指定剪切性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_shear_property', u'查看剪切性能'),
            ('add_shear_property', u'添加剪切性能'),
            ('delete_shear_property', u'删除剪切性能'),
            ('change_shear_property', u'修改剪切性能'),
        )


class BondProperties(models.Model):
    """
    弯曲性能model，定义了弯曲性能的相关属性
    """
    bond_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                          verbose_name='bond_properties_id')  # 弯曲性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    temperature = models.TextField(
        null=True, blank=True, verbose_name='temperature')  # 温度
    sample_range = models.TextField(
        null=True, blank=True, verbose_name='sample_range')  # 样品标距
    sample_width = models.TextField(
        null=True, blank=True, verbose_name='sample_width')  # 宽
    sample_height = models.TextField(
        null=True, blank=True, verbose_name='sample_height')  # 高
    flexural_modulus = models.TextField(
        null=True, blank=True, verbose_name='flexural_modulus')  # 挠曲模量
    bond_strength = models.TextField(
        null=True, blank=True, verbose_name='bond_strength')  # 弯曲强度
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'bond_properties'  # 内嵌类指定弯曲性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_bond_property', u'查看弯曲性能'),
            ('add_bond_property', u'添加弯曲性能'),
            ('delete_bond_property', u'删除弯曲性能'),
            ('change_bond_property', u'修改弯曲性能'),
        )


class TorsionalProperties(models.Model):
    """
    扭转性能model，定义了扭转性能的相关属性
    """
    torsional_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                               verbose_name='torsional_properties_id')  # 扭曲性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    temperature = models.TextField(
        null=True, blank=True, verbose_name='temperature')  # 温度
    sample_range = models.TextField(
        null=True, blank=True, verbose_name='sample_range')  # 样品标距
    sample_diameter = models.TextField(
        null=True, blank=True, verbose_name='sample_diameter')  # 直径
    torsional_modules = models.TextField(
        null=True, blank=True, verbose_name='torsional_modules')  # 扭转模量
    torsional_strength = models.TextField(
        null=True, blank=True, verbose_name='torsional_strength')  # 扭转强度
    torque = models.TextField(null=True, blank=True,
                              verbose_name='torque')  # 扭矩
    torsional_angle = models.TextField(
        null=True, blank=True, verbose_name='torsional_angle')  # 扭转角
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'torsional_properties'  # 内嵌类指定扭转性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_torsional_property', u'查看扭转性能'),
            ('add_torsional_property', u'添加扭转性能'),
            ('delete_torsional_property', u'删除扭转性能'),
            ('change_torsional_property', u'修改扭转性能'),
        )


class FractureToughness(models.Model):
    """
    断裂韧性model，定义了断裂韧性的相关属性
    """
    fracture_toughness_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                             verbose_name='fracture_toughness_id')  # 断裂韧性id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    temperature = models.TextField(
        null=True, blank=True, verbose_name='temperature')  # 温度
    sample_range = models.TextField(
        null=True, blank=True, verbose_name='sample_range')  # 样品标距
    sample_width = models.TextField(
        null=True, blank=True, verbose_name='sample_width')  # 宽
    sample_thickness = models.TextField(
        null=True, blank=True, verbose_name='sample_thickness')  # 样品厚度
    open_depth = models.TextField(
        null=True, blank=True, verbose_name='open_depth')  # 开口深度
    open_shape = models.TextField(
        null=True, blank=True, verbose_name='open_shape')  # 开口形状
    fracture_toughness = models.TextField(
        null=True, blank=True, verbose_name='fracture_toughness')  # 断裂韧性
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'fracture_toughness'  # 内嵌类指定断裂韧性表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_fracture_toughness', u'查看断裂韧性'),
            ('add_fracture_toughness', u'添加断裂韧性'),
            ('delete_fracture_toughness', u'删除断裂韧性'),
            ('change_fracture_toughness', u'修改断裂韧性'),
        )


class FrictionalWearProperties(models.Model):
    """
    摩擦磨损性能model，定义了摩擦磨损性能相关的属性
    """
    frictional_wear_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                                     verbose_name='frictional_wear_properties_id')  # 摩擦磨损性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    sample_shape = models.TextField(
        null=True, blank=True, verbose_name='sample_shape')  # 样品形状
    sample_thickness = models.TextField(
        null=True, blank=True, verbose_name='sample_thickness')  # 样品厚度
    sample_diameter = models.TextField(
        null=True, blank=True, verbose_name='sample_diameter')  # 直径
    test_temperature = models.TextField(
        null=True, blank=True, verbose_name='test_temperature')  # 测试温度
    sample_quality_before_test = models.TextField(null=True, blank=True,
                                                  verbose_name='sample_quality_before_test')  # 测试前样品质量
    sample_volume_before_test = models.TextField(null=True, blank=True,
                                                 verbose_name='sample_volume_before_test')  # 测试前样品体积
    friction_test = models.TextField(
        null=True, blank=True, verbose_name='friction_test')  # 摩擦方式
    test_time = models.TextField(
        null=True, blank=True, verbose_name='test_time')  # 测试时间
    applied_load = models.TextField(
        null=True, blank=True, verbose_name='applied_load')  # 施加载荷
    friction_velocity = models.TextField(
        null=True, blank=True, verbose_name='friction_velocity')  # 摩擦速率
    friction_distance = models.TextField(
        null=True, blank=True, verbose_name='friction_distance')  # 摩擦距离
    friction_coefficient = models.TextField(
        null=True, blank=True, verbose_name='friction_coefficient')  # 摩擦系数
    mass_wear = models.TextField(
        null=True, blank=True, verbose_name='mass_wear')  # 质量磨损量
    volume_wear = models.TextField(
        null=True, blank=True, verbose_name='volume_wear')  # 体积磨损量
    mass_wear_rate = models.TextField(
        null=True, blank=True, verbose_name='mass_wear_rate')  # 质量磨损速率
    volume_wear_rate = models.TextField(
        null=True, blank=True, verbose_name='volume_wear_rate')  # 体积磨损速率
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'frictional_properties'  # 内嵌类指定摩擦磨损性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_frictional_property', u'查看摩擦磨损性能'),
            ('add_frictional_property', u'添加摩擦磨损性能'),
            ('delete_frictional_property', u'删除摩擦磨损性能'),
            ('change_frictional_property', u'修改摩擦磨损性能'),
        )


class Hardness(models.Model):
    """
    硬度model，定义了硬度管理相关模块
    """
    hardness_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                   verbose_name='hardness_id')  # 硬度管理id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    sample_shape = models.TextField(
        null=True, blank=True, verbose_name='sample_shape')  # 样品形状
    test_temperature = models.TextField(
        null=True, blank=True, verbose_name='test_temperature')  # 测试温度
    test_load = models.TextField(
        null=True, blank=True, verbose_name='load')  # 载荷
    hardness = models.TextField(
        null=True, blank=True, verbose_name='hardness')  # 硬度
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'hardness'  # 内嵌类指定硬度表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_hardness', u'查看硬度'),
            ('add_hardness', u'添加硬度'),
            ('delete_hardness', u'删除硬度'),
            ('change_hardness', u'修改硬度'),
        )


class ServiceProperties(models.Model):
    """
    服役性能model，定义了服役性能相关属性
    """
    service_properties_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                             verbose_name='service_properties_id')  # 服役性能id
    sample_name = models.TextField(
        null=True, blank=True, verbose_name='sample_name')  # 样品名称
    alloy_code = models.ForeignKey(AlloyPhaseDiagram, on_delete=models.CASCADE,
                                   db_column='alloy_code', verbose_name='alloy_code')  # 合金代码
    data_source = models.TextField(
        null=True, blank=True, verbose_name='data_source')  # 数据来源
    sample_status = models.TextField(
        null=True, blank=True, verbose_name='sample_status')  # 样品状态
    equipment_name = models.TextField(null=True, blank=True,
                                      verbose_name='equipment_name')  # 设备名称
    equipment_manufacturer = models.TextField(null=True, blank=True,
                                              verbose_name='equipment_manufacturer')  # 设备厂家
    device_model = models.TextField(
        null=True, blank=True, verbose_name='device_model')  # 设备型号
    encapsulation_way = models.TextField(
        null=True, blank=True, verbose_name='encapsulation_way')  # 封装方式
    flux_type = models.TextField(
        null=True, blank=True, verbose_name='flux_type')  # 助焊剂类型
    temperature = models.TextField(
        null=True, blank=True, verbose_name='temperature')  # 温度
    cost_time = models.TextField(
        null=True, blank=True, verbose_name='cost_time')  # 耗时
    falling_life = models.TextField(
        null=True, blank=True, verbose_name='falling_life')  # 跌落寿命
    drop_impact_performance_curve = models.TextField(null=True, blank=True,
                                                     verbose_name='drop_impact_performance_curve')  # 跌落冲击性能曲线
    thermal_fatigue_cycle_interval = models.TextField(null=True, blank=True,
                                                      verbose_name='thermal_fatigue_cycle_interval')  # 热疲劳循环区间值
    thermal_cycles = models.TextField(
        null=True, blank=True, verbose_name='thermal_cycles')  # 热循环次数
    thermal_fatigue_cycle_failure = models.TextField(null=True, blank=True,
                                                     verbose_name='thermal_fatigue_cycle_failure')  # 热疲劳循环失效率
    ductile_brittle_shift_temperature = models.TextField(null=True, blank=True,
                                                         verbose_name='ductile_brittle_shift_temperature')  # 韧脆转变温度
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'service_properties'  # 内嵌类指定服役性能表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_service_property', u'查看服役性能'),
            ('add_service_property', u'添加服役性能'),
            ('delete_service_property', u'删除服役性能'),
            ('change_service_property', u'修改服役性能'),
        )
